#!/bin/bash
base="`echo $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`"
if [[ -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]]
then
    if [ `echo -ne "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | wc -l` -eq "1" ]
    then
        quoted=$(echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | 
                 head -n 1 |
                 awk 'BEGIN { FS = "\n" } { printf "\"%s\"", $1 }' | sed -e s#\"\"##)
        if [[ `echo "$quoted" | xargs head -q -c 4 | tr 'A' 'X' | tr '\177' 'A'` == "AELF" ]]
        then
            beesu - "cd \"$base\" && $quoted"
        else
            zenity --info --title="Execute Application" --text="I won't run a non-application without a terminal."
        fi
    else
        zenity --info --title="Execute Application" --text="I won't run more than one application at once."
    fi
fi
# F12
/bin/true
